package com.atguigu.oss.controller.OssController;

import com.atguigu.commonutils.R;
import com.atguigu.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/edu_oss/eduoss")
@CrossOrigin
@Api(tags = "头像上传API")
public class OssController {

    @Autowired
    private OssService os;

    @ApiOperation(value = "上传头像图片")
    @PostMapping("/uploadFile")
    public R uploadFile(MultipartFile file) {
        String url = os.uploadFile(file);
        return R.ok().data("url", url);
    }
}
